package io.renren.modules.job.controller;

import com.github.pagehelper.PageInfo;
import io.renren.common.pojo.R;
import io.renren.modules.common.BaseController;
import io.renren.modules.job.entity.ScheduleJobLogEntity;
import io.renren.modules.job.pojo.ScheduleJobLogQuery;
import io.renren.modules.job.service.ScheduleJobLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 定时任务日志
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2016年12月1日 下午10:39:52
 */
@RestController
@RequestMapping("/sys/scheduleLog")
@Api(description = "定时任务日志接口")
public class ScheduleJobLogController extends BaseController{
	@Autowired
	private ScheduleJobLogService scheduleJobLogService;
	
	/**
	 * 定时任务日志列表
	 */
	@RequestMapping(value = "/list",method = RequestMethod.GET)
	@PreAuthorize("hasAuthority('sys:schedule:log')")
	@ApiOperation("获取定时任务日志列表")
	public R<PageInfo<ScheduleJobLogEntity>> list(ScheduleJobLogQuery query){
		PageInfo<ScheduleJobLogEntity> pageInfo = scheduleJobLogService.queryPage(query);
		return R.ok(pageInfo);
	}
	
	/**
	 * 定时任务日志信息
	 */
	@RequestMapping(value = "/info/{logId}",method = RequestMethod.GET)
	@ApiOperation("获取定时任务日志信息")
	public R<ScheduleJobLogEntity> info(@ApiParam("日志ID") @PathVariable("logId") Long logId){
		ScheduleJobLogEntity log = scheduleJobLogService.queryObject(logId);
		return R.ok(log);
	}
}
